package com.example.user

import android.content.Intent
import android.os.Bundle
import android.widget.RadioGroup
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.alibaba.android.arouter.facade.annotation.Route
import com.example.lib_base.mvvm.BaseActivity
import com.example.user.databinding.ActivityUserBinding
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
@Route(path = "/user/UserActivity")
class UserActivity : BaseActivity<ActivityUserBinding, UserViewModel>() {

    override fun initView() {

        binding.tvUpgrade.setOnClickListener {
            val builder = AlertDialog.Builder (this)
            builder.setTitle ("会员升级")
            builder.setMessage ("是否需要升级会员以获取更多专属权益？升级后可享受无广告体验、高清画质优先加载以及专属客服等特权。")
// 取消按钮
            builder.setNegativeButton ("取消") { dialog, _ ->
                dialog.dismiss ()
            }
// 确定按钮，点击跳转到支付页面
            builder.setPositiveButton ("确定") { dialog, _ ->
                val intent = Intent (this, PayamActivity::class.java)
// 可携带会员相关信息到支付页面，如会员类型、价格等
                intent.putExtra ("memberType", "年度会员")
                intent.putExtra ("price", 198.00)
                startActivity (intent)
                dialog.dismiss ()
            }
            val dialog = builder.create ()
            dialog.setCancelable (false) // 点击对话框外部不关闭对话框
            dialog.show ()
// 可根据需要设置按钮文字颜色
            dialog.getButton (AlertDialog.BUTTON_NEGATIVE)?.setTextColor (ContextCompat.getColor (this, R.color.black))
            dialog.getButton (AlertDialog.BUTTON_POSITIVE)?.setTextColor (ContextCompat.getColor (this, R.color.yellow))

            val memberStatus = intent.getStringExtra("member_status")
            if (memberStatus != null) {
                // 假设你有一个 TextView 用于显示会员状态
                binding.tvPlatinumMember.text = memberStatus
                // 如果有多个状态选项，可以遍历并设置选中样式
                // 例如：遍历RadioButton或List，设置选中
            }
        }
        // 返回按钮
        binding.ivBack.setOnClickListener {
            finish()
        }

        // 升级按钮点击事件
        binding.memberCard.findViewById<android.widget.TextView>(R.id.tvUpgrade)?.setOnClickListener {
        }

    }


    override fun initData() {

    }
    }

